package org.cloudie.docs.editor.client.resources.icons;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.Image;

public class IconsHelper {
  public static final IconsImageBundle icons =
    (IconsImageBundle)GWT.create(IconsImageBundle.class);
  
  public static Image getIcon(String identifier, boolean small) {
    String url = getIconUrl(identifier, small);
	if (small) {
	  Image img = new Image(url);
	  img.setPixelSize(16, 16);
	  return img;
	} else {
	  Image img = new Image(url);
	  img.setPixelSize(48, 48);
	  return img;
	}
  }
  
  public static String getIconUrl(String identifier, boolean small) {
    if (small) {
	  return "/images/icons/small/" + identifier + ".png";
	} else {
	  return "/images/icons/large/" + identifier + ".png";
	}
  }
  
  public static String getMimetypeIconIdentifier(String type, boolean small) {
    String icon = "mimetypes/application_x_zerosize";
	if (type.equalsIgnoreCase("document")) {
      icon = "mimetypes/application_vnd.ms_word";
	} else if (type.equalsIgnoreCase("spreadsheet")) {
	  icon = "mimetypes/application_vnd.ms_excel";
	} else if (type.equalsIgnoreCase("drawing")) {
	  icon = "mimetypes/drawing";
	} else if (type.equalsIgnoreCase("presentation")) {
	  icon = "mimetypes/presentation";
	} else if(type.equalsIgnoreCase("desktop")) {
	  icon = "mimetypes/application_desktop";
	} else if(type.equalsIgnoreCase("tex")) {
	  icon = "mimetypes/tex";
	} else if(type.equalsIgnoreCase("folder")) {
	  icon = "filesystems/folder_network";
	}
	return icon;
  }
}
